<?php
class town_npc_skill_file{

    public function  __construct() {
    }

	/**
	 * 获取镇妖塔NPC 技能
	 * $level 级别
	 * $idx   加成序号
	 * return 加成值
	 */
	public static function get_cache_skill($level,$idx){
		$fp = fopen(PROJECT_ROOT."/cache/town/npc_skill_file.cache","r");//读取缓存

		$buffer = fgets($fp,4096);

		$arr = unpack("Irow/Imax",$buffer);

		$startRow = ($arr['max']*($idx-1)+$level)-1;

		$searchRow = strlen($buffer) + $startRow * $arr['row'];

		if($searchRow > 0){
			fseek($fp, $searchRow);
		}
		$content = "";
		if(!feof($fp)){
			$buffer = fgets($fp, 4096);
			$arr = unpack("a36/a36value",$buffer);

			$content = $arr['value'];
		}
		fclose($fp);
		return $content;
	}

	/**
	 * 获得同一等级下的多技能
	 */
	public static function get_cache_skill_assoc($level,$arrIdx) {
		$returnVal = array();
		foreach($arrIdx as $idx){
			if($idx!=0){
				$val = self::get_cache_skill($level,$idx);
				$returnVal[$idx] = $val;
			}
		}

		return $returnVal;
	}
}
?>
